<div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
    <form data-toggle="ajaxsearch" data-options="{searchDatagrid:$.CurrentNavtab.find('#deviceinfo')}">
        <fieldset>
            <div style="margin:0; padding:1px 5px 5px;">
                <span>设备名称：</span>
                <input type="text" id="list-deviceName" name="deviceName" class="form-control" size="10">
                <span>所属用户：</span>
                <input type="text"  id="list-ownerName" name="ownerName" class="form-control" size="10">
                <span>设备信息：</span>
                <input type="text"  id="list-deviceInfo" name="deviceInfo" class="form-control" size="10">
                <span>设备型号：</span>
                <input type="text"  id="list-deviceModel" name="deviceModel" class="form-control" size="10">
                <div class="btn-group">
                    <button type="submit" class="btn-green" data-icon="search">开始搜索！</button>
                    <button type="reset" class="btn-orange" data-icon="times">重置</button>
                    <button onclick="exportData()" type="button" class="btn-orange">导出</button>
                </div>
            </div>
        </fieldset>
    </form>
</div>
<div class="bjui-pageContent">
    <table class="table table-bordered" id="deviceinfo" data-toggle="datagrid" data-options="{
        height: '100%',
        local: 'remote',
        showToolbar: true,
        toolbarItem: 'add, edit, del',
        dataUrl: '/sysmanage/device/listdata.do',
        editMode: {dialog:{width:'1000',height:800,mask:true,title:'编辑'}},
        editUrl: '/sysmanage/device/add.do?{sn}',
        delUrl: '/sysmanage/device/del.do',
        paging: {pageSize:20, pageCurrent:1},
        linenumberAll: false,
        filterThead:false,
        exportOption: {type:'file', options:{url:'/sysmanage/device/listdata.do', loadingmask:true}},
        sortAll: true
    }">
        <thead>

        <tr>
            <th data-options="{name:'sn',align:'center' }" width="160px">sn</th>
            <th data-options="{name:'devicename',align:'center'}" width="140px">设备名称</th>
            <th data-options="{name:'imei',align:'center'}" width="160px">设备imei</th>
            <th data-options="{name:'imsi',align:'center'}" width="160px">imsi</th>
            <th data-options="{name:'devicemodel',align:'center'}" width="150px">设备型号</th>
            <th data-options="{name:'deviceinfo',align:'center'}" width="160px">设备信息</th>
            <th data-options="{name:'location',align:'center'}" width="220px">设备位置</th>
            <th data-options="{name:'upper',align:'center'}" width="90px">水位上限<br/>(米)</th>
            <th data-options="{name:'lower',align:'center'}" width="90px">水位下限<br/>(米)</th>
            <th data-options="{name:'reportCycle',align:'center'}" width="100px">上报周期<br/>(分钟)</th>
            <th data-options="{name:'sampleCycle',align:'center'}" width="100px">采样周期<br/>(分钟)</th>
            <th data-options="{render:'setUserName',align:'center'}" width="100px">所属用户</th>
            <th data-options="{render:'setcreatedate'}" align="center" width="200px">创建时间</th>
        </tr>
        </thead>
    </table>
</div>
<script type="text/javascript">
    function setUserName(value, data) {
        if (data.deviceownerByOwnerid!=null){
            return data.deviceownerByOwnerid.name;
        }
        return "";
    }
    function setcreatedate(value, data) {
        return formatDate(new Date(data.createdate));
    }
    function exportData() {
        var deviceName = $("#list-deviceName").val();
        var ownerName = $("#list-ownerName").val();
        var deviceInfo = $("#list-deviceInfo").val();
        var deviceModel = $("#list-deviceModel").val();
        var form = $("<form>");   //定义一个form表单
        form.attr('style', 'display:none');   //在form表单中添加查询参数
        form.attr('target', '');
        form.attr('method', 'post');
        form.attr('action', "/sysmanage/device/listdataimport");
        var input1 = $('<input>');
        input1.attr('type', 'hidden');
        input1.attr('name', 'deviceName2');
        input1.attr('value', deviceName);
        var input2 = $('<input>');
        input2.attr('type', 'hidden');
        input2.attr('name', 'ownerName2');
        input2.attr('value', ownerName);
        var input3 = $('<input>');
        input3.attr('type', 'hidden');
        input3.attr('name', 'deviceInfo2');
        input3.attr('value', deviceInfo);
        var input4 = $('<input>');
        input4.attr('type', 'hidden');
        input4.attr('name', 'deviceModel2');
        input4.attr('value', deviceModel);


        $('body').append(form);  //将表单放置在web中
        form.append(input1);
        form.append(input2);
        form.append(input3);
        form.append(input4);
        form.submit();
    }
</script>